const { readFile } = require('./file')
const { RESULT } = require('../config/index')
const { dataPaging } = require('../utils/index')

// 查询所有表名
const queryAllCollection = (cb) => {
  readFile('t_object', (res) => {
    RESULT.data = res;
    RESULT.total = res.length;
    cb(RESULT)
  })
}
// 查询表数据
const queryDataToCollection = (body, cb) => {
  const { tableName, page, pageSize, } = body
  readFile(tableName, (res) => {
    let list=dataPaging(res,page,pageSize)
    RESULT.data = list;
    RESULT.total = res.length;
    cb(RESULT)
  })
}
exports.queryAllCollection = queryAllCollection
exports.queryDataToCollection = queryDataToCollection